# -*- encoding:utf-8 -*-
"""
@作者：ven
@文件名：yamlUtil.py
@时间：2021-10-19  9:40
@文档说明:
"""
import os
from pprint import pprint

import yaml

from utils.pathUtil import config_path,data_path


def get_yamls_data(dir):
    resList = []
    f = open(dir, 'r', encoding='utf-8')
    res = yaml.load_all(f, Loader=yaml.FullLoader)  # load_all针对yml中有分隔符的，存在多组数据的
    for item in res:
        resList.append(item)
    return resList


def get_yaml_data(dir):
    with open(dir, 'r', encoding='utf-8') as f:
        return yaml.safe_load(f.read())


def get_yaml_case_data(dir):
    '''
    :param dir: yml文件的路径"../data/irs_system_V1.0.yml"
    :return: 返回测试用例中的请求体和预期结果
    '''
    resList = []
    f = open(dir, 'r', encoding='utf-8')
    res = yaml.load(f, Loader=yaml.FullLoader)  # load针对yml中仅一组数据，无分隔符
    for item in res:
        resList.append((item['data'], item['resp']))
    return resList


if __name__ == '__main__':
     #print(get_yaml_data(os.path.join(config_path, 'shifts.yaml'))['shifts']['行政班四签制']['shifts_data'])

     print(get_yaml_data(os.path.join(data_path, 'rfidCard.yaml'))['card'])


